package com.xuecheng.content.feignClient;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 远程调用媒资的降级处理类
 * @author 冯佳鑫 又菜又爱学
 * @version 1.0
 * @DATE now()
 */
@Slf4j
@Component
public class MediaServiceClientFallbackFactory implements FallbackFactory<MediaServiceClient> {
    @Override
    public MediaServiceClient create(Throwable throwable) {
        //匿名内部类
        return new MediaServiceClient() {
            //降级方法
            @Override
            public String upload(MultipartFile filedata, String objectName) throws IOException {
                log.debug("内容管理远程调用媒资服务发生熔断并进行降级处理，异常信息:{}",throwable.toString()
                ,throwable);
                return null;
            }
        };
    }
}
